﻿using OpenReflect.Domain.Contracts;
using OpenReflect.Domain.Contracts.Declarations;
using OpenReflect.Domain.Contracts.HasMarkers;

namespace OpenReflect.Domain.Model
{
	public class Namespace : INamespace, ICodeItem
	{
		public Namespace(INamespaceDeclaration declaration, INamespaceBody body)
		{
			NamespaceBody = body;
			Declaration = declaration;
		}

		#region INamespace Members

		public string Name { get; set; }

		public INamespaceBody NamespaceBody { get; private set; }

		public INamespaceDeclaration Declaration { get; private set; }

		INamespaceBody IHasBody<INamespaceBody>.Body
		{
			get { return NamespaceBody; }
		}

		public INamespaceDeclaration NamespaceDeclaration
		{
			get { return Declaration; }
		}

		IDeclaration IHasDeclaration.Declaration
		{
			get { return Declaration; }
		}

		#endregion

		public override bool Equals(object obj)
		{
			var objAsNameSpace = obj as INamespace;
			if (objAsNameSpace == null)
			{
				return false;
			}
			return objAsNameSpace.Name == Name;
		}

		public override int GetHashCode()
		{
			return base.GetHashCode();
		}
	}
}